#pragma once
#include"comLib\global.h"

class RPCFW_EXPORT NetPacket{
public:
	NetPacket();
	void writeImage(uchar *buffer,int width,int height,int widthBytes);
	void write(const uchar *buffer, uint bufSize);

	void preAllocatBuf(uint bufSize);
	void emptyBuf();
	const uchar* getPtr();
	uint	getSize();
	uint getInt(uint pos=0);
	int getWidth();
	int getHeight();
	int getWidthBytes();
	int getChannel();

	~NetPacket();

private:
	void allocateBuf(uint bufSize);
	void checkBuffer(uint bufSize);

private:
	uchar *m_Ptr=nullptr;
	uint m_iBufSize=0;
	uchar m_iRealSize = 0;

	uint m_width;
	uint m_height;
	uint m_widthBytes;
};